#override("css")
<link href="#springUrl('/static/css/bootstrap.min.css')" rel="stylesheet">
#end

#override("body")
<body class="white-bg">
<form id="baseForm"  class="form-horizontal m-t" autocomplete="off" data-validator-option="{timely:2, theme:'default', focusCleanup:true}">
	<div class="wrapper wrapper-content form-item">
		<div class="panel panel-default">
			<div class="row">
				<input type="hidden" name="id" value="$!{genScheme.id}">
				<input type="hidden" id="flag" name="flag" value="$!{genScheme.flag}">

				<br />
				<div class="col-xs-12">
					<div class="form-group">
						<label class="col-md-2 control-label">方案名称:</label>
						<div class="col-md-4">
							<input type="text" class="form-control" id="name" name="name" maxlength="200" value="$!{genScheme.name}" data-rule="方案名称:required">
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group">
						<label class="col-md-2 control-label">模板分类:</label>
						<div class="col-md-4">
							<select class="form-control" name="category" data-rule="required">
								<option value="">无</option>
								#foreach($dict in $config.categoryList)
								<option value="$dict.value" #if($dict.value eq $genScheme.category) selected #else '' #end>$!{dict.label}</option>
								#end
							</select>
							<span class="help-inline">
										生成结构:{包名}/{模块名}/{分层(dao,entity,service,web)}/{子模块名}/{java类}
									</span>
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group">
						<label class="col-md-2 control-label">生成包路径:</label>
						<div class="col-md-4">
							<input type="text" class="form-control" id="packageName" name="packageName" maxlength="200" value="$!{genScheme.packageName}" data-rule="生成包路径:required">
							<span class="help-inline">建议模块包:com.unitd.modules</span>
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group">
						<label class="col-md-2 control-label">生成模块名:</label>
						<div class="col-md-4">
							<input type="text" class="form-control" id="moduleName" name="moduleName" maxlength="200" value="$!{genScheme.moduleName}" data-rule="生成模块名:required">
							<span class="help-inline">可理解为子系统名,例如 param</span>
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group">
						<label class="col-md-2 control-label">生成子模块名:</label>
						<div class="col-md-4">
							<input type="text" class="form-control" id="subModuleName" name="subModuleName"
								   maxlength="200" value="$!{genScheme.subModuleName}" aria-required="true"
								   aria-invalid="true">
							<span class="help-inline">可选，分层下的文件夹，例如 </span>
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group" style="display: none;">
						<label class="col-md-2 control-label">生成功能描述:</label>
						<div class="col-md-4">
							<input type="text" class="form-control" id="functionName" name="functionName" maxlength="200" value="$!{genScheme.functionName}">
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group" style="display: none;">
						<label class="col-md-2 control-label">生成功能名:</label>
						<div class="col-md-4">
							<input type="text" class="form-control" id="functionNameSimple" name="functionNameSimple" maxlength="200" value="$!{genScheme.functionNameSimple}">
							<span class="help-inline">用作功能提示，如：保存“某某”成功</span>
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group">
						<label class="col-md-2 control-label">生成功能作者:</label>
						<div class="col-md-4">
							<input type="text" class="form-control" id="functionAuthor" name="functionAuthor" maxlength="200" value="$!{genScheme.functionAuthor}" data-rule="成功能作者:required">
							<span class="help-inline">功能开发者</span>
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group">
						<label class="col-md-2 control-label">业务表名:</label>
						<div class="col-md-4">
							<input type=text id="genTableComments" name="genTableComments" class="form-control" value="$!{genTableComments}" onclick="showDialog()" readonly="readonly" data-rule="成功能作者:required">
							<input type="hidden" id="genTableNames" name="genTableNames" value="$!{genScheme.genTableNames}">
							<span class="help-inline">生成的数据表,一对多情况下请选择主表</span>
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group">
						<label class="col-md-2 control-label">备注:</label>
						<div class="col-md-4">
							<input type="text" class="form-control" id="remarks" name="remarks" maxlength="200"  value="$!{genScheme.remarks}">
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group">
						<label class="col-md-2 control-label">生成选项:</label>
						<div class="col-md-4  i-checks">
							<label class="checkbox-inline ">
								<input type="checkbox" class="form-control" id="replaceFile" name="replaceFile" value="true">是否替换现有文件
							</label>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</form>
</body>
#end

#override("js")
<script type="text/javascript">
	// 页面加载的时候调用的js
	$(function () {
		if ("$!{action}" == "doView") {
			$('input,select,textarea,checkbox,radio', $('form[id="baseForm"]')).attr('disabled', true);
		}
	});

	$("#baseForm").validator({
		valid: function (form) {
			var me = this;
			// 提交表单之前,hold住表单,防止重复提交
			me.holdSubmit();

			$.ajax({
				url: "#springUrl('/gen/genScheme/doEdit')",
				data: $(form).serialize(),
				type: "POST",
				success: function (data) {
					if (data.success) {
						parent.refreshTable(); 					// 重新刷新父页面
						parent.layer.alert('处理数据成功', {icon: 1}, function () {
							parent.layer.closeAll();
						});
					} else {
						parent.layer.alert(data.message, {icon: 2}, function (index) {
							//失败,提交表单成功后,释放hold,如果不释放hold,就变成了只能提交一次的表单
							me.holdSubmit(false);
							parent.layer.close(index);

						});
					}
				}
			});
		}
	});
	// 调用方法实现保存
	function save() {
		$('#flag').val('0');
		// 手工触发表单验证
		$("#baseForm").trigger('validate');
	}
	// 调用方法实现保存并声称文件
	function create() {
		$('#flag').val('1');
		// 手工触发表单验证
		$("#baseForm").trigger('validate');
	}

	/* 转到显示选择表类型树页面 */
	function showDialog() {
		var genTableNames = $("#genTableNames").val();
		var url = "#springUrl('/gen/genTable/toTableTree?genTableNames=" + genTableNames + "')";
		layer_show_btn("选择数据表类型", url, 400, null);
	}
</script>
#end
#extends("/common/base.html")